﻿/*!
* jQuery superCalendar plugin:
*
* version 0.1 2011-03-10
* Requires (1)jQuery v1.4.2 or later (2)
* Dual licensed under the MIT and GPL Version 2 licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Authors: Pang Sung Mo
* Company : Kongyoung DB
*/

(function ($) {
	$.fn.superImageBrowser = function (method) {
		if (methods[method]) {
			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
		} else if (typeof method === 'object' || !method) {
			return methods.init.apply(this, arguments);
		} else {
			$.error('Method ' + method + ' does not exist on jQuery.tooltip');
		}
	};

	var this_super;
	var inner_html = "";
	var labelnum;
	var index;
	inner_html += "<div class='leftSection'>";

	inner_html += "<div class='button_layer'>";
	inner_html += "<input type='button' value='<' class='left_page' />";
	inner_html += "<input type='label' class='labelname' value='1'>";
	inner_html += "<input type='button' value='>' class='right_page' />";
	inner_html += "</div>";

	inner_html += "<div class='image_layer'>";
	inner_html += "<div><img class='left_img row1' title='숙제검사해요' src='' /><img class='left_img row1' src='' /><img class='left_img row1' src='' /></div>";
	inner_html += "<div><img class='left_img row2' src='' /><img class='left_img row2' src='' /><img class='left_img row2' src='' /></div>";
	inner_html += "<div><img class='left_img row3' src='' /><img class='left_img row3' src='' /><img class='left_img row3' src='' /></div>";
	inner_html += "<div><img class='left_img row4' src='' /><img class='left_img row4' src='' /><img class='left_img row4' src='' /></div>";
	inner_html += "</div>";

	inner_html += "<div class='button_layer'>";
	inner_html += "<input type='button' value='<' class='left_page' />";
	inner_html += "<input type='label' class='labelname' value='1'>";
	inner_html += "<input type='button' value='>' class='right_page' />";
	inner_html += "</div>";
	inner_html += "</div>";

	inner_html += "<div class='rightSection'>";
	inner_html += "<div class='lefts'>";
	inner_html += "<input type='button' value='<' class='left' />";
	inner_html += "</div>";
	inner_html += "<div class='rights'>";
	inner_html += "<input type='button' value='>' class='right' />";
	inner_html += "</div>";
	inner_html += "<div class='rightSections'>";
	inner_html += "</div>";
	inner_html += "</div>";

	var methods = {
		init: function () {
			this_super = $(this);
			this_super.append(inner_html);
		},

		img_Save: function (imgarr) {		
			
			$(".left_img").each(function () {
				var count = 0;
				$(this).attr('src', imgarr[count]);
				count++;
			});	
			
			$(".left_img").click(function(){
					$(".rightSections").html("<img src=' " +$(this).attr('src') + " 'class='full' />");
					index = $(".left_img").index(this);
			});

			$(".left_page").click(function(){
				var count = 0;
				$(".left_img").each(function () {
					$(this).attr('src', imgarr[count]);
					count++;
				});
				index = $(".left_img").index($(".left_img"));
				if(index<11){
					$(".labelname").attr("value",1+"PAGE");
				}
			});
			
			$(".left").click(function(){
				var src = $(".left_img").eq(index-1).attr('src');
				$(".rightSections").html("<img src=' " +src+ " 'class='full' />");
				index--;
			});

			$(".right").click(function(){
				var src = $(".left_img").eq(index+1).attr('src');
				$(".rightSections").html("<img src=' " +src+ " 'class='full' />");
				index++
			});

			$(".left_img").each(function () {
				if ($(this).attr('src') == null || $(this).attr('src') == "") {
					$(this).attr('src', '/image/icotitlesqu02.gif');
				}
			});
		},

		init_img:function(imgarr2) {
			$(".right_page").click(function () {
				var count = 0;
			$(".left_img").each(function () {
				$(this).attr('src', imgarr2[count]);
				count++;
			});					
			index = $(".left_img").index($(".left_img"));
				if(index<11){
					$(".labelname").attr("value",2+"PAGE");
				}
			});	
		},
	}
})(jQuery);
